package se.sll.service.catalogue.common.validation;

import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import se.sll.service.catalogue.common.exception.ConstraintViolationException;

/**
 *
 * @author khaleddaham
 * @author Jiri Uosukainen
 */
public class FacadeRESTValidator {

    public void validate(Object request, Validator validator) throws ConstraintViolationException {

        Set<ConstraintViolation<Object>> constraintViolations = validator.validate(request);
        if (!constraintViolations.isEmpty()) {
            throw new ConstraintViolationException(constraintViolations);
        }
    }
}
